/*
* @Author: jingyu.ma
* @Date:   2017-07-12 21:25:30
* @Last Modified by:   jingyu.ma
* @Last Modified time: 2017-08-06 21:34:31
*/

import initialState from '../state';
import {date2time} from 'common/date';

function myPublishReducer(state = initialState.myPublish, action){
    switch(action.type){
        //我的技能列表
        case 'GET_MY_SKILL_SUCCESS':
            let mySkillList = state.mySkill.list
            action.data.rows.map(item => {
                mySkillList.push(item);
                item.dtime = date2time(item.dtime);
            })
            return Object.assign({},state,{
                mySkill:{
                    list: mySkillList,
                    pageNo: action.data.currentPageNumber,
                    total: action.data.total
                }
            })
        // 我的需求列表
        case 'GET_MY_DEMAND_SUCCESS':
            let myDemandList = state.myDemand.list
            action.data.rows.map(item => {
                myDemandList.push(item);
                item.dtime = date2time(item.dtime);
            })
            return Object.assign({},state,{
                myDemand:{
                    list: myDemandList,
                    pageNo: action.data.currentPageNumber,
                    total:action.total
                }
            })
        default :
            return state;
    }
}

export default myPublishReducer;